package com.atguigu.gmall.realtime.publisher;

import org.apache.commons.lang3.time.DateUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDateUtil {

    public static String getYesterday(String today){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date todayDate = simpleDateFormat.parse(today);
            Date yesterdayDate = DateUtils.addDays(todayDate, -1);
            return simpleDateFormat.format(yesterdayDate);
        } catch (ParseException e) {
            e.printStackTrace();
            throw  new RuntimeException("日期转换失败！");
        }

    }



}
